//
//  RightCell.m
//  南京大牌档
//
//  Created by student on 14-1-11.
//  Copyright (c) 2014年 无锡第三团队. All rights reserved.
//

#import "RightCell.h"

@implementation RightCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initSubview];
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)initSubview
{
  
    _billImg=[[UIImageView alloc]initWithFrame:CGRectZero];
    _billImg.backgroundColor=[UIColor redColor];
    [self.contentView addSubview:_billImg];
    
    _billTitle=[[UILabel alloc]initWithFrame:CGRectZero];
    _billTitle.font=[UIFont boldSystemFontOfSize:13];
    _billTitle.backgroundColor=[UIColor clearColor];
    _billTitle.textAlignment = 1;
    [self.contentView addSubview:_billTitle];
    
    _billPrice=[[UILabel alloc]initWithFrame:CGRectZero];
    _billPrice.font=[UIFont boldSystemFontOfSize:13];
    _billPrice.backgroundColor=[UIColor clearColor];
    _billPrice.textAlignment = 1;
    [self.contentView addSubview:_billPrice];
    

    
    _billNum=[[UILabel alloc]initWithFrame:CGRectZero];
    _billNum.backgroundColor=[UIColor clearColor];
    _billNum.font=[UIFont boldSystemFontOfSize:13];
    _billNum.textAlignment = 1;
    [self.contentView addSubview:_billNum];
    
    _billPlus=[[UIButton alloc]initWithFrame:CGRectZero];
    _billPlus.backgroundColor=[UIColor clearColor];
    _billPlus.tag=1;
    [self.contentView addSubview:_billPlus];
    
    _billMinus=[[UIButton alloc]initWithFrame:CGRectZero];
    _billMinus.backgroundColor=[UIColor clearColor];
    _billMinus.tag=0;
    [self.contentView addSubview:_billMinus];
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    _billImg.frame=CGRectMake(0, 1, 50, 38);
    
    _billTitle.frame=CGRectMake(50, 0, 100, 40);
    
    _billMinus.frame=CGRectMake(150, 0, 40, 40);
    [_billMinus setImage:[UIImage imageNamed:@"button_minus"] forState:UIControlStateNormal];
    
    _billNum.frame=CGRectMake(190, 10, 20, 20);
    
    _billPlus.frame=CGRectMake(210, 0, 40, 40);
    [_billPlus setImage:[UIImage imageNamed:@"button_plus"] forState:UIControlStateNormal];
    
    _billPrice.frame=CGRectMake(250, 0, 40, 40);
    
    [_billPlus addTarget:self action:@selector(billButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
    [_billMinus addTarget:self action:@selector(billButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
    _billPlus.backgroundColor=[UIColor clearColor];
    _billMinus.backgroundColor=[UIColor clearColor];
}

-(void)translateRightCellData:(NSArray *)array Tag:(int)tag
{
    NSArray  *translateRightArray=[NSArray arrayWithArray:array];
    NSNumber *translateRightTag=[NSNumber numberWithInt:tag];
    NSDictionary *dic = @{@"Array":translateRightArray,@"Tag":translateRightTag};
    [[NSNotificationCenter defaultCenter]postNotificationName:@"translateRightCellData" object:self userInfo:dic];
}

-(void)billButtonPressed:(UIButton *)button
{
    [self translateRightCellData:_billCellArray Tag:button.tag];
}
@end
